#coding=utf-8
import datetime

from apscheduler.schedulers.blocking import BlockingScheduler

from utils.weiboUtil import weibo_util

# 60s = 1 min ;  1 * 60 = 1 hour ;
# 指定5小时爬取一次微博热点
duration = 5

def my_job():
    # 初始化爬虫配置
    weibo_util.init_config()
    # 爬取微博搞笑内容
    weibo_util.get_daily_funny()
    # 爬取微博情感类内容
    weibo_util.get_daily_motion()

if __name__ == '__main__':
    scheduler = BlockingScheduler()
    scheduler.add_job(my_job, 'interval', hours=duration, next_run_time=datetime.datetime.now())
    scheduler.start()
